package com.aaa.ssm.service.impl;

import com.aaa.ssm.dao.ThemeDao;
import com.aaa.ssm.entity.Theme;
import com.aaa.ssm.service.ThemeService;
import com.aaa.ssm.util.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ fileName:ThemeServiceImpl
 * @ description:
 * 景区主题
 * @ date: 2023/3/29 15:17
 * @ version:1.0.0
 */
@Service
public class ThemeServiceImpl implements ThemeService {
    @Resource
    private ThemeDao themeDao;
    @Override
    public List<Theme> queryAll() {
        return themeDao.queryAll();
    }

    /**
     * 分页带参查询
     * @param page
     * @return
     */
    @Override
    public PageInfo queryPage(Page<Theme> page) {
        PageHelper.startPage(page.getPageNo(), page.getPageSize());
        return new PageInfo(themeDao.queryByParam(page.getData()));
    }
    @Override
    public PageInfo SysQueryByParam(Page<Theme> page) {
        //设置页码和每页信息显示数量
        PageHelper.startPage(page.getPageNo(),page.getPageSize());
        //实例化PageInfo 把查询寻结果作为参数放入里面
        PageInfo pageInfo = new PageInfo(themeDao.SysQueryByParam(page.getData()));
        return pageInfo;
    }
    @Override
    public int add(Theme theme) {
        return themeDao.add(theme);
    }

    @Override
    public int update(Theme theme) {
        return themeDao.update(theme);
    }

    @Override
    public int deleteById(int code) {
        return themeDao.deleteById(code);
    }
}
